package com.hgw.Demo11_VisitorPattern.examples;

/**
 * Data time:2021/12/21 20:27
 * StudentID:2019112118
 * Author:hgw
 * Description: 财务部类，充当具体访问者类
 */
public class FADepartment extends Department{

    // 实现财务部对全职员工的访问
    public void visit(FulltimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double weekWage = employee.getWeeklyWage();
        if (workTime > 40) {
            weekWage = weekWage + (workTime - 40) *100;
        } else if (workTime < 40) {
            weekWage = weekWage - (40 - workTime) * 80;
            if (weekWage < 0) {
                weekWage = 0;
            }
        }
        System.out.println("全职工" + employee.getName() + "实际工资为：" + weekWage + "元");
    }

    // 实现财务部对兼职员工的访问
    public void visit(ParttimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double hourWage = employee.getHourWage();
        System.out.println("临时工" + employee.getName() + "实际工资为：" + workTime * hourWage + "元");
    }
}
